package com.xinchao.service.impl;

import com.xinchao.dao.ChargeMapper;
import com.xinchao.exception.ServiceException;
import com.xinchao.service.ChargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.rmi.ServerException;

/**
 * 费用ServiceImpl
 *
 * @author dxy
 * @date 2018/11/9 10:40
 */
@Service(value = "chargeService")
public class ChargeServiceImpl implements ChargeService {
	@Autowired
	private ChargeMapper chargeMapper;

	/**
	 * 通过广告主ID获取总费用
	 *
	 * @param advertiserId 广告主ID
	 * @return BigDecimal（总费用）
	 * @throws ServiceException
	 */
	@Override
	public BigDecimal getTotalChargeByAdvertiserId(Long advertiserId) throws ServiceException {
		if (advertiserId == null) {
			throw new ServiceException("输入参数不能为空");
		}
		return chargeMapper.getTotalChargeByAdvertiserId(advertiserId);
	}

}
